<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<title>修改密码</title>
<link rel="stylesheet" href="layui/css/layui.css">
<link rel="stylesheet" href="static/css/style.css">
</head>

<body>
	<div class="container">
		<fieldset class="layui-elem-field layui-field-title"
			style="margin-top: 20px;">
			<legend>修改密码</legend>
		</fieldset>
		<form class="layui-form" style="margin-top: 70px;">
			<div class="layui-form-item">
				<label class="layui-form-label">帐号</label>
				<div class="layui-input-block">
					<input type="text" autocomplete="off" placeholder="请输入原密码"
						class="layui-input zhanghao" style="width: 300px;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">原密码</label>
				<div class="layui-input-block">
					<input type="password" autocomplete="off" placeholder="请输入原密码"
						class="layui-input oldPwd" style="width: 300px;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">密码</label>
				<div class="layui-input-block">
					<input type="password" autocomplete="off" placeholder="请输入新密码"
						class="layui-input newPwd" style="width: 300px;">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确定密码</label>
				<div class="layui-input-block">
					<input type="password" autocomplete="off" placeholder="请确认密码"
						class="layui-input newPwd1" style="width: 300px;">
				</div>
			</div>
		</form>

		<div style="margin-left: 200px; margin-top: 50px;">
			<button type="button" class="layui-btn layui-btn-lg layui-btn-normal"
				id="save">保存</button>
		</div>
	</div>
	<script type="text/javascript " src="js/jquery.min.js "></script>
	<script src="js/common.js "></script>
	<script src="layui/layui.js "></script>
	<script src="layer-v3.1.1/layer/mobile/layer.js"></script>
	<script>
		var layer;
		$(function() {
			var userId = localStorage.getItem("backUid");
			$(".zhanghao").text(localStorage.getItem("backPhone"));
			layui.use([ 'table', 'form', 'layer' ], function() {
				layer = layui.layer;
			})
			$("#save").click(function() {
				var oldPwd = $(".oldPwd").val();
				var newPwd = $(".newPwd").val();
				var newPwd1 = $(".newPwd1").val();
				var zhanghao = $(".zhanghao").val();
				if (oldPwd == null || oldPwd.trim().length < 1) {
					return layer.msg('请输入原密码');
				}
				if (newPwd == null || newPwd.trim().length < 1) {
					return layer.msg('请输入新密码');
				}
				if (newPwd1 == null || newPwd1.trim().length < 1) {
					return layer.msg('请输入确认密码');
				} else if (newPwd1 != newPwd) {
					return layer.msg('请再次确认密码');
				} else if (zhanghao == null || zhanghao.trim().length < 1) {
					return layer.msg('请输入帐号');
				}
				$.ajax({
					type : "POST", //提交方式 
					url : baseurl + "/backuser/updatePwdPhone", //路径 
					dataType : 'json',
					data : {
						backUid : userId,
						oldPwd : oldPwd,
						newPwd : newPwd,
						phone : zhanghao
					}, //数据，这里使用的是Json格式进行传输 
					success : function(data) { //返回数据根据结果进行相应的处理 
						if (data.meta.code == 200) {
							layer.msg('修改成功 ', {
								icon : 1
							});
							setTimeout(function() {
								top.window.location.href = "login.html";
							}, 400)

						} else {
							layer.msg('修改失败', {
								icon : 5
							});
						}
					}
				});
			})
		})
	</script>
</body>

</html>